﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace AChance.Tool.Func
{
    public static class AppUtilHelper
    {
        public static class Const
        {
            public const string VARCHAR = "A";
            public const string DECIMAL = "B";
            public const string INT = "C";
            public const string CHAR = "D";
            public const string TEXT = "E";
            public const string IMAGE = "F";
            public const string ACH_ENUM = "G";
            public const string ACH_DATE = "O";
            public const string ACH_TIME = "P";
            public const string ACH_REF = "X";
        }
        public static string ChanegeType(string ConstType,string defindType="")
        {
            if (ConstType == Const.DECIMAL)
            {
                return "double";
            }
            else if (ConstType == Const.INT)
            {
                return "int";
            }
            else if (ConstType == Const.IMAGE)
            {
                return "byte[]";
            }
            else if (ConstType == Const.ACH_ENUM)
            {
                return defindType;
            }
            else
            {
                return "string";
            }
        }
        public static string Save(string path, string content)
        {
            string dir = path.Substring(0, path.LastIndexOf("\\") + 1);
            if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
            File.WriteAllText(path, content);
            return path;
        }
    }
}
